package com.taotao.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.taotao.entity.EasyUIDataGridResult;
import com.taotao.mapper.TbItemMapper;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemExample;
import com.taotao.service.ItemService;

@Service
public class ItemServiceImpl implements ItemService {

	@Autowired
	private TbItemMapper tbItemMapper;

	@Override
	public TbItem getItemById(Long itemid) {
		// TODO Auto-generated method stub
		System.out.println("service start itemid:" + itemid);
		TbItem tbitem = tbItemMapper.selectByPrimaryKey(itemid);
		System.out.println("service end itemid:" + itemid);
		return tbitem;
	}

	@Override
	public EasyUIDataGridResult getItemList(int page, int rows) {
		// TODO Auto-generated method stub
		TbItemExample tbItemExample = new TbItemExample();
		PageHelper.startPage(page, rows);
		List<TbItem> tbItemList = tbItemMapper.selectByExample(tbItemExample);
		PageInfo<TbItem> pageinfo = new PageInfo<>(tbItemList);
		EasyUIDataGridResult easyUIDataGridResult = new EasyUIDataGridResult(
				pageinfo.getTotal(), tbItemList);
		return easyUIDataGridResult;
	}

}
